<script setup lang="ts">
import type { EaDiscountCoupon } from './type'

const baseApi = '/ea/ea-discount-coupon'

const { loadData, loading, model } = useDetail<EaDiscountCoupon>(baseApi)

defineExpose({ init: loadData })
</script>

<template>
  <el-empty v-if="!Object.keys(model).length" v-loading="loading" />
  <el-descriptions v-else v-loading="loading" :column="1" border>
    <el-descriptions-item label="优惠券名" label-class-name="item-label" label-align="right">
      <span class="txt-short">
        {{ model.name }}
      </span>
    </el-descriptions-item>
    <el-descriptions-item label="可用金额" label-class-name="item-label" label-align="right">
      <span class="txt-short">
        {{ model.usableAmount }}
      </span>
    </el-descriptions-item>
    <el-descriptions-item label="优惠券金额" label-class-name="item-label" label-align="right">
      <span class="txt-short">
        {{ model.discountValue }}
      </span>
    </el-descriptions-item>
    <!--    <el-descriptions-item label="优惠类型" label-class-name="item-label" label-align="right">
          <el-tag v-if="model.discountTypeLabel" :color="model.discountTypeLabel.ext?.color" effect="dark" type="info">
            {{ model.discountTypeLabel?.label }}
          </el-tag>
        </el-descriptions-item>-->
    <!--    <el-descriptions-item label="最大可减免金额" label-class-name="item-label" label-align="right">
          <span class="txt-short">
            {{ model.discountValue }}
          </span>
        </el-descriptions-item>-->
    <el-descriptions-item label="可用天数" label-class-name="item-label" label-align="right">
      <span class="txt-short">
        {{ model.usableDays }}
      </span>
    </el-descriptions-item>
    <!--    <el-descriptions-item label="优惠券描述" label-class-name="item-label" label-align="right">
          <span class="txt-short">
            {{ model.description }}
          </span>
        </el-descriptions-item>-->
    <el-descriptions-item label="获得类型" label-class-name="item-label" label-align="right">
      <el-tag v-if="model.gainTypeLabel" :color="model.gainTypeLabel.ext?.color" effect="dark" type="info">
        {{ model.gainTypeLabel?.label }}
      </el-tag>
    </el-descriptions-item>
    <el-descriptions-item label="获得数量" label-class-name="item-label" label-align="right">
      <span class="txt-short">
        {{ model.gainNum }}
      </span>
    </el-descriptions-item>
  </el-descriptions>
</template>

<style scoped lang="scss">
.el-descriptions {
  :deep(.el-descriptions__header) {
    margin: 0 10px 12px;
  }

  :deep(.item-label) {
    width: 130px;
  }
}
</style>
